package top.cdmrx.demo.edu.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;
import top.cdmrx.common.R;
import top.cdmrx.demo.edu.entity.subject.OneSubject;
import top.cdmrx.demo.edu.service.SubjectService;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-09-14
 */
@RestController
@RequestMapping("/eduSubject/subject")
@CrossOrigin
public class SubjectController {

    @Autowired
    private SubjectService subjectService;


    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){

        subjectService.saveSubject(file);
        return R.success();
    }


    //课程分类列表（树形结构）
    @GetMapping("getAllSubject")
    public R getAllSubject(){

        List<OneSubject> list=subjectService.getAllOneAndTwoSubject();

        return R.success().data("list",list);

    }

}

